package com.up.cloudfeiyibackend.controller;

import com.up.cloudfeiyibackend.constant.InheritorMessageConstant;
import com.up.cloudfeiyibackend.dto.InheritorApplicationDto;
import com.up.cloudfeiyibackend.result.Result;
import com.up.cloudfeiyibackend.service.InheritorService;
import com.up.cloudfeiyibackend.vo.InheritorApplicationVO;
import com.up.cloudfeiyibackend.vo.InheritorVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 非遗传承人相关接口
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/inheritor")
public class InheritorController {

    private final InheritorService inheritorService;

    /**
     * 申请非遗传承人
     *
     * @param inheritorApplicationDto
     * @return
     */
    @PostMapping("/apply")
    public Result<Void> apply(@RequestBody InheritorApplicationDto inheritorApplicationDto){
        inheritorService.apply(inheritorApplicationDto);
        return Result.success(InheritorMessageConstant.APPLY_SUCCESS);
    }

    /**
     * 查询用户申请列表
     *
     * @return
     */
    @GetMapping("/myApplications")
    public Result<List<InheritorApplicationVO>> getMyApplications() {
        List<InheritorApplicationVO> inheritorApplicationVOList = inheritorService.getUserApplications();
        return Result.success(InheritorMessageConstant.GET_SUCCESS, inheritorApplicationVOList);
    }


    /**
     * 查询我的传承人身份
     *
     * @return
     */
    @GetMapping("/myInheritor")
    public Result<InheritorVO> getMyInheritor() {
        return inheritorService.getMyInheritor();
    }
}
